<?php
session_start();
$key=$_COOKIE['userkey'];//这么做很有必要，不然会获取不到session的值
if(!isset($_SESSION[$key])){
    echo '<a href="../login.php">前往登录</a>';
    die;
}
$user_pwd=$_SESSION[$key]['user_pwd'];
$old_pwd=$_POST['old_pwd'];
$new_pwd=$_POST['new_pwd'];
echo 'user_pwd:'.$user_pwd;
echo '<br/>';
echo 'old_pwd:'.$old_pwd;
echo '<br/>';
echo 'new_pwd:'.$new_pwd;
echo '<br/>';
if($user_pwd==$old_pwd){
    if($user_pwd!=$new_pwd){
        $_SESSION[$key]['user_pwd']=$_POST['new_pwd'];
        echo '您的新密码是'.$_SESSION[$key]['user_pwd'].'<br/>';
        echo '修改密码成功';
    }
    else{
        echo '旧密码不能跟新密码重复';
    }
}
else{
    echo '输入的旧密码错误';
}


